package com.jt.utils;

import com.jt.pojo.User;

/**
 * @author dc
 * @Classname ThreadLocalUtil
 * @Date 2020/2/29 14:24
 */
public class ThreadLocalUtil {

    private static ThreadLocal<User> thread=new ThreadLocal<>();

    /**将User用户信息存入本地线程中*/
    public static void setUser(User user){
        thread.set(user);
    }

    /**从线程中获取用户信息*/
    public static User getUser(){
       return thread.get();
    }

    /**清空数据,防止递归调用造成内存泄漏*/
    public static void remove(){
        thread.remove();
    }
}
